package cn.dengta.webapp.trade.dto;

import cn.dengta.context.rpc.CachedConfig;
import cn.dengta.context.rpc.CachedConfigManager;
import lombok.Getter;
import lombok.Setter;

/**
 * @author lizhichao
 * @since 2024-05-13
 */
@Setter
@Getter
public class PayRiskVideoConfig {

	/** 金额上限 */
	private Integer amountLimit;
	/** 是否开启倍数弹窗次方 */
	private Boolean multiplePopup;

	public Boolean isEnable() {
		return amountLimit > 0;
	}

	public static CachedConfig<PayRiskVideoConfig> cache() {
		return PayRiskVideoConfig.InstanceHolder.INSTANCE;
	}

	public static PayRiskVideoConfig getDefault() {
		final PayRiskVideoConfig cfg = new PayRiskVideoConfig();
		cfg.amountLimit = 10000;
		cfg.multiplePopup = true;
		return cfg;
	}

	private static final class InstanceHolder {

		static final CachedConfig<PayRiskVideoConfig> INSTANCE = CachedConfigManager.create("pay_risk_video_config", PayRiskVideoConfig.class, PayRiskVideoConfig::getDefault);

	}

}
